<style type="text/css">
label.error { float: none; color: red; padding-left: .5em; vertical-align: top; }
</style>

<script>
function refreshGroupPP(data)
{
$('#configPpdefaultgroup option').remove();
$.each(data, function(key, value)
{
$('#configPpdefaultgroup').
          append($("<option></option>").
		  attr("value",value).
          text(value)); 
});
}

$(document).ready(function() {
	$("#tabs").tabs();
	$("#UserViewConfigForm").validate();
	});
	
if (timer!=null)
	clearInterval(timer);


function toggleTCP() {
   	if($('#useTcpBukkit').is(':checked')) {
		$('#tcpbukkitdiv').slideDown('fast');
        $('#tcpbukkitdiv :input').removeAttr('disabled');
    } else {
		$('#tcpbukkitdiv').slideUp('fast');
        $('#tcpbukkitdiv :input').attr('disabled', true);
    }   
}
function toggleRT() {
   	if($('#useRemoteToolkit').is(':checked')) {
		$('#remotetoolkitdiv').slideDown('fast');
        $('#remotetoolkitdiv :input').removeAttr('disabled');
    } else {
		$('#remotetoolkitdiv').slideUp('fast');
        $('#remotetoolkitdiv :input').attr('disabled', true);
    }   
}
function togglePP() {
   	if($('#usePermissionsPlugin').is(':checked')) {
		$('#ppdiv').slideDown('fast');
        $('#ppdiv :input').removeAttr('disabled');
    } else {
		$('#ppdiv').slideUp('fast');
        $('#ppdiv :input').attr('disabled', true);
    }   
}
function toggleMapSystem()
{
//alert($('#configMapsystem').val());
	if($('#configMapsystem').val()!='')
	{
	
		$('#mapsystemdiv').slideDown('fast');
	}
	else
	{
		$('#mapsystemdiv').slideUp('fast');
	}
}
function addtemplateplugin()
{
$('#mctemplatepluginId').val('');
$('#mctemplatepluginName').val('');
$('#mctemplatepluginUrl').val('');
$('#mctemplatepluginConfig').val('');
	$.blockUI({
		theme: true,
		css:{ 
			padding:        0, 
			margin:         0, 
			width:          '400px'
			},
		title:    'Add plugin template',
		fadeIn:  300,
		message: $('#addplugin')});
}
function edittemplateplugin(data)
{
$('#mctemplatepluginId').val(data[0]);
$('#mctemplatepluginName').val(data[1]);
$('#mctemplatepluginUrl').val(data[2]);
$('#mctemplatepluginConfig').val(data[3]);
	$.blockUI({
		theme: true,
		css:{ 
			padding:        0, 
			margin:         0, 
			width:          '400px'
			},
		title:    'Add plugin template',
		fadeIn:  300,
		message: $('#addplugin')});
}

function edituser(data)
{
$('#UserId').val(data['id']);
$('#UserLogin').val(data['username']);
$('#UserFullname').val(data['fullname']);
$('#UserEmail').val(data['email']);
$('#UserGroup').val(data['group']);
	$.blockUI({
		theme: true,
		css:{ 
			padding:        0, 
			margin:         0, 
			width:          '400px'
			},
		title:    'Add user',
		fadeIn:  300,
		message: $('#edituser')});	
}
</script>
<?php
$displaydivBukkit = "";
$displaydivRT = "";
$displaydivPP = "";
$displaymapdiv = "";
if (!$this->data['config']["useTcpBukkit"])
{
	$displaydivBukkit = 'style="display:none"';
}
if (!$this->data['config']["useRemoteToolkit"])
{
	$displaydivRT = 'style="display:none"';
}
if (!$this->data['config']["usePermissionsPlugin"])
{
	$displaydivPP = 'style="display:none"';
}
if (!$mapsystem || $mapsystem=='no')
{
	$displaymapdiv = 'style="display:none"';
}
?>
<div id="tabs">
<ul>
<li><a href="#fragment-1"><span><?php __('Config'); ?></span></a></li>
<li><a href="#fragment-4"><span><?php __('Admin password'); ?></span></a></li>
<li><a href="#fragment-2"><span><?php __('Plugins'); ?></span></a></li>
<li><a href="#fragment-6"><span><?php __('Users'); ?></span></a></li>
<li><a href="#fragment-3"><span><?php __('Items'); ?></span></a></li>
<li><a href="#fragment-7"><span><?php __('Website permissions'); ?></span></a></li>
<li><a href="#fragment-5"><span><?php __('About'); ?></span></a></li>
</ul>
<div id="fragment-1">
<?php echo $this->element('config_general'); ?>
</div>
<div id="fragment-4">
<div id="PasswordTab" style="padding-bottom:5px">
<?php
echo $this->element('PasswordTab');
?>
</div>
</div>
<div id="fragment-2">
<table class="box-table-a">
<thead>
<tr>
<th scope='col'><?php __('Name of plugin');?></th>
<th scope='col'><?php __('Url of plugin');?></th>
<th scope='col'><?php __('Path to config file');?></th>
<th scope='col'></th>
<th scope='col'></th>
</tr>
</thead>
<tbody id="tableplugins">
<?php echo $this->element('tableplugin'); ?>
</tbody>
<tfoot>
<tr><td colspan="5" align="center"><a class="ui-icon ui-icon-plus" href="#" onclick="addtemplateplugin();"></a></td></tr>
</tfoot>
</table>
</div>
<div id="fragment-6">
<?php echo $this->element('config_users'); ?>
</div>
<div id="fragment-3">
<?php echo $this->element('items'); ?>
</div>
<div id="fragment-7">
<?php echo $this->element('config_sitepermissions'); ?>

</div>
<div id="fragment-5">
<?php echo $this->element('config_about'); ?>
</div>
</div>

<div id="addplugin" class="dialog" style="display:none;">
<?php
echo $form->create('mctemplateplugin');
echo $form->input('id',array('div'=>false,'type'=>'hidden'));
echo $form->input('name',array('div'=>false));
echo "<br/><sup>(".__("Name of the plugin",true).")</sup><br/>";
echo $form->input('url',array('div'=>false));
echo "<br/><sup>(".__("Homepage of the plugin",true).")</sup><br/>";
echo $form->input('config',array('div'=>false));
echo "<br/><sup>(".__("Becareful, the path must be relative to the minecraft path",true).")</sup><br/>";
?>
<center>
<?php
echo $js->submit(
	'save',
	array('div'=>false,'url'=>array('controller'=>'private','action'=>'saveplugintemplate'),'update'=>'#tableplugins','complete' => '$.unblockUI();'));
?>
<input type="reset" value="cancel" onclick="$.unblockUI();">
</center>
<?php echo $form->end(); ?>
</div>

<div id="edituser" class="dialog" style="display:none;">
<?php
echo $form->create('User');
echo $form->input('id',array('div'=>false,'type'=>'hidden'));
echo $form->input('login',array('div'=>false));
echo "<br/><br/>";
//echo "<br/><sup>(".__("Login",true).")</sup><br/>";
echo $form->input('fullname',array('div'=>false));
echo "<br/><br/>";
//echo "<br/><sup>(".__("Fullname",true).")</sup><br/>";
echo $form->input('email',array('div'=>false));
//echo "<br/><sup>(".__("Email",true).")</sup><br/>";
echo "<br/><br/>";
echo $form->input('password',array('div'=>false));
//echo "<br/><sup>(".__("Password",true).")</sup><br/>";
echo "<br/><br/>";
echo $form->input('confirmpassword',array('type'=>'password','equalTo'=>'#UserPassword','div'=>false,'label'=>__('Confirm password',true)));
//echo "<br/><sup>(".__("Confirm password",true).")</sup><br/>";
echo "<br/><br/>";
echo $form->label('group','Select group');
echo $form->select('group',array("1"=>"admin","2"=>"registered"));
?>
<center>
<?php
echo $js->submit(
	'save',
	array('div'=>false,'url'=>array('controller'=>'private','action'=>'edituser'),'update'=>'#fragment-6','complete' => '$.unblockUI();'));
?>
<input type="reset" value="cancel" onclick="$.unblockUI();">
</center>
<?php echo $form->end(); ?>
</div>
<?php echo $this->Js->writeBuffer(); ?>
